import {Injectable} from '@angular/core';
import {Observable} from 'rxjs';
import {HttpClient, HttpRequest} from '@angular/common/http';

@Injectable({
  providedIn: 'root'
})
export class CoverService {

  constructor(private http: HttpClient) {
  }

  // 查询封面类别信息，不包含封面信息
  selectCoverType(coverType): Observable<any> {
    return this.http.post<any>(`/gdd/cover/selectCoverType`, coverType);
  }

  // 查询封面类别信息，包含封面信息
  selectCoverTypeJoinCover(coverType): Observable<any> {
    return this.http.post<any>(`/gdd/cover/selectCoverTypeJoinCover`, coverType);
  }

  // 查询封面信息, 不包含封面类别信息
  selectCover(cover): Observable<any> {
    return this.http.post<any>(`/gdd/cover/selectCover`, cover);
  }

  // 分页查询封面信息，包含封面类别信息
  selectCoverByPage(itemForPage, pageNumber, pageSize): Observable<any> {
    return this.http.post<any>(`/gdd/cover/selectCoverByPage/${pageNumber}/${pageSize}`, itemForPage);
  }

  // 修改封面类别信息
  modifyCoverType(coverTypeFormValue): Observable<any> {
    return this.http.post<any>(`/gdd/cover/modifyCoverType`, coverTypeFormValue);
  }

  // 修改封面信息
  modifyCover(coverFormValue): Observable<any> {
    return this.http.post<any>(`/gdd/cover/modifyCover`, coverFormValue);
  }

  // 添加封面信息(上传图片)
  importCover(formData: FormData): Observable<any> {
    return this.http.request(new HttpRequest('POST', '/gdd/file/importCover', formData));
  }

  // 删除封面类别信息
  deleteCoverType(id): Observable<any> {
    return this.http.post<any>(`/gdd/cover/deleteCoverType`, id);
  }

  // 删除封面信息
  deleteCover(id): Observable<any> {
    return this.http.post<any>(`/gdd/cover/deleteCover`, id);
  }

}
